/* License Notice:
**
** This program is free software: you can redistribute it and/or modify
**    it under the terms of the GNU General Public License as published by
**    the Free Software Foundation, either version 3 of the License, or
**    (at your option) any later version.
** This program is distributed in the hope that it will be useful,
**   but WITHOUT ANY WARRANTY; without even the implied warranty of
**   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
**   GNU General Public License for more details.
** You should have received a copy of the GNU General Public License
**   along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
 * @file keyboard.hpp
 * @author TooOld2Rock'nRoll
 * @date 2025/02/13
 * @brief Interface for dealing with everything keyboard related.
 *
 * @todo This interface is not implemented yet, need to keep the input map somewhere!
 */
#ifndef _CONTROLLER_HPP_
#define _CONTROLLER_HPP_

/*---- Includes ----*/
#include "interfaces/input_device.hpp"


/*---- Enumerations ----*/
#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief Expected keys used for input.
 *
 * Based on a standard console controllers (like PlayStation, Xbox or Nintendo).<br>
 * Keys can be mapped from any input hardware (not just joysticks) and not all keys need to be valid in the game.
 *
 * @see https://retropie.org.uk/docs/RetroArch-Configuration/#default-core-controls-for-all-emulators
 */
typedef enum _controller_button_map_t_
{
    /* Directional Pad */
    DPAD_LEFT = 0,///< Directional Pad Left
    DPAD_RIGHT,   ///< Directional Pad Right
    DPAD_UP,      ///< Directional Pad Up
    DPAD_DOWN,    ///< Directional Pad Down

    /* Action Buttons */
    ACTION_A, ///< Action Button A
    ACTION_B, ///< Action Button B
    ACTION_X, ///< Action Button X
    ACTION_Y, ///< Action Button Y

    /* Shoulder Top Buttons */
    SHOULDER_LEFT, ///< Left Shoulder Top Button
    SHOULDER_RIGHT,///< Right Shoulder Top Button

    /* Left Analog Stick */
    ANLG_LEFT_CLICK,///< Left Analog Stick Click Action
    ANLG_LEFT_LEFT, ///< Left Analog Stick Left
    ANLG_LEFT_RIGHT,///< Left Analog Stick Right
    ANLG_LEFT_UP,   ///< Left Analog Stick Up
    ANLG_LEFT_DOWN, ///< Left Analog Stick Down

    /* Right Analog Stick */
    ANLG_RIGHT_CLICK,///< Right Analog Stick Click Action
    ANLG_RIGHT_LEFT, ///< Right Analog Stick Left
    ANLG_RIGHT_RIGHT,///< Right Analog Stick Right
    ANLG_RIGHT_UP,   ///< Right Analog Stick Up
    ANLG_RIGHT_DOWN, ///< Right Analog Stick Down

    /* Shoulder Bottom Buttons */
    TRIGGER_LEFT, ///< Left Shoulder Bottom Button
    TRIGGER_RIGHT,///< Right Shoulder Bottom Button

    /* System Buttons */
    //useful to keep them last, as many mappings require to handle these two exclusively.
    SELECT,///< Select Button
    START, ///< Start/Pause Button

    ///Just keep track of max number of keys
    _button_max
} controller_button_map_t;//end input_map

#ifdef __cplusplus
} //extern "C"
#endif


/*---- Global Variables ----*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
///List of Input Map names to use in debug, keep up with input_map_t!
static const char *sa_input_map_names[controller_button_map_t::_button_max] =
{
    "DPAD_LEFT", "DPAD_RIGHT", "DPAD_UP", "DPAD_DOWN",
    "ACTION_A", "ACTION_B", "ACTION_X", "ACTION_Y",
    "SHOULDER_LEFT", "SHOULDER_RIGHT",
    "ANLG_LEFT_CLICK", "ANLG_LEFT_LEFT", "ANLG_LEFT_RIGHT", "ANLG_LEFT_UP", "ANLG_LEFT_DOWN",
    "ANLG_RIGHT_CLICK", "ANLG_RIGHT_LEFT", "ANLG_RIGHT_RIGHT", "ANLG_RIGHT_UP", "ANLG_RIGHT_DOWN",
    "TRIGGER_LEFT", "TRIGGER_RIGHT",
    "SELECT", "START"
};//end sa_input_map_names
#pragma GCC diagnostic pop


/*---- Class Declaration ----*/
/**
 * @brief Hardware controller abstraction.
 */
class Controller : public InputDevice<controller_button_map_t>
{
    private:


    protected:


    public:
        Controller ();
        ~Controller ();

        virtual void update () override {  };

        virtual key_state getKeyState (controller_button_map_t scancode) const override { return key_state::_key_state_max; };
};//END Controller

#endif //_CONTROLLER_HPP_

